package com.example.wyh.bluetoothpro;

import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.LinkedList;

/**
 * Created by WYH on 17/9/12.
 */

public class BlueAdapter extends BaseAdapter {

    private LinkedList<BluetoothDevice> data;
    private Context context;

    public BlueAdapter() {

    }

    public BlueAdapter(LinkedList data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = LayoutInflater.from(context).inflate(R.layout.list_item, parent, false);

        TextView name = (TextView)convertView.findViewById(R.id.name);
        TextView address = (TextView)convertView.findViewById(R.id.address);

        name.setText(data.get(position).getName());
        address.setText(data.get(position).getAddress());

        return convertView;
    }
}


